
const B = [];

for (let i = 0; i < 8; i++) {
for (let j = 0; j < 8; j++) {
for (let k = 0; k < 8; k++) {
    if(i === j || j === k || i === k) continue;
    B.push([i,j,k]);
} } }

const FS = [
    (p, n) => p & n,
    (p, n) => ~p & n,
    (p, n) => p & ~n,
    (p, n) => ~p & ~n,
    (p, n) => p | n,
    (p, n) => ~p | n,
    (p, n) => p | ~n,
    (p, n) => ~p | ~n,
    (p, n) => p ^ n,
    (p, n) => ~p ^ n,
    (p, n) => p ^ ~n,
    (p, n) => ~p ^ ~n,
]

let x, y, z, a, b, c;

/*
x:'0',y:'1',z:'_',a:'0',b:'1',c:'2'
(x,a) -> (x,a)
(x,b) -> (y,a)
(x,c) -> (x,b)
(y,a) -> (y,b)
(y,b) -> (x,c)
(y,c) -> (y,c)
(z,a) -> (z,a)
(z,b) -> (x,b)
(z,c) -> (z,c)
*/

const ck = (f1, f2, p1, n1, p2, n2) => (f1(p1, n1) === p2) && (f2(p1, n1) === n2);

(() => {
    let count = 0;
    for (const p of B) {
    for (const n of B) {
        [x, y, z] = p;
        // [x, y] = p;
        [a, b, c] = n;

        let rd = [
            [x, a, x, a], [x, b, y, a], [x, c, x, b],
            [y, a, y, b], [y, b, x, c], [y, c, y, c],
            [z, a, z, a], [z, b, z, b], [z, c, z, c],
        ]

        for (const f1 of FS) {
        for (const f2 of FS) {

                if (rd.some(k => !ck(f1, f2, k[0], k[1], k[2], k[3]))) continue;

                count++;

                console.log(`x:${x.toString(2)},y:${y.toString(2)},` +
                    `a:${a.toString(2)},b:${b.toString(2)},c:${c.toString(2)}`);
                console.log(`f1:${f1.toString()}\nf2:${f2.toString()}`)

                // if (count > 20) return null;
        } }
    } }

    console.log('count:', count);
})();